#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2024/3/21 18:49
# @Author : 闫峰
# @File    : pop_choice_products_list_syc_bei.py
# !/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2024/3/20 13:46
# @Author : 闫峰
# @File    : test_monitor_inf_listing.py
from datetime import datetime, timedelta

import requests
from retrying import retry

from common.setting import ensure_path_sep
from third_services.aliexpress.utils import ErpDesUtil
from utils.mysqlUtils.db_pool import Database
from utils.logging_tool.init_logger import init_logger
from utils.noticeUtils.dingtalkControl import DingTalkSendMsg
from utils.rabbitmq.rabbitmq_utils import RabbitMq_
from utils.times_tool.time_control import count_time
from utils.otherutils.MyThreadPool import MyThreadPool

INFO, ERROR, WARNING = init_logger()


class Test:
    znkd_db = Database(ensure_path_sep("\\config\\znkd_mysql_config.yaml"), "znkd_database_prod")

    @count_time
    def test__(self):
        """
        海量监控速卖通平台 在线产品数 550个店铺
        涉及数据库
        :return:
        """
        get_task_list = """
        SELECT id,UserTokenSecretAccessKey,page,source_id,ChannelSellerId
        FROM monitor.monitor_aliexpress_listing_all_task
        where status=2 
        """
        db_java_test = Database(ensure_path_sep("\\config\\shopeev2_config.yaml.bak"), "test_jdw_database")
        task_list = db_java_test.fetch_all_tuple(get_task_list,())
        print(f"线程池任务数={len(task_list)}个")
        # 发送到MQ中
        mp = RabbitMq_(queue_name="aliexpress_pop_choice_product_monitor_task_all",
                       routing_key="aliexpress_pop_choice_product_monitor_task_all")
        for task in task_list:
            mp.send_message(str(task))



if __name__ == '__main__':
    Test().test__()
